import * as type from '../mutation'

const state = {
	all:[]
}

const mutations = {
	[type.RECEIVE_PRODUCTS] (state,{products}){
		state.all = products;
	},
	[type.ADD_TO_CART] (state,{id}){
		state.all.find(p => p.id === id).inventory--;
	},
	[type.REMOVE_FROM_CART] (state,{id,quantity}){
		state.all.find(p => p.id === id).inventory += quantity;
	}
}

export default {
	state,
	mutations
}